--[[
	Homework 7.5
	Henrique "Nican" Polido
	CS2223, Prof. Guttman
	Due: Tuesday, 24 Nov 2010, 2:00
]]

require("directed_graphs")
require("undirected_graphs")
require("graph")
require("connected_components")

function table.contains( t, val )
	for _, v in pairs( t ) do
		if v == val then
			return true
		end
	end
	return false	
end

function table.icontains( t, val )
	for _, v in ipairs( t ) do
		if v == val then
			return true
		end
	end
	return false	
end

local undirectedGraphs = {
	graph.New(ug1),
	graph.New(ug2),
	graph.New(ug3),
	graph.New(ug4)
}

local directedGraphs = {
	["cities"] = graph.New(cities_graph_no_names, true),
	graph.New(g1, true),
	graph.New(g2, true),
	graph.New(g3, true),
	graph.New(g4, true),
	graph.New(g5, true)
}

print("\n\n----------- Connected Components -----------")
for k, graph in pairs( undirectedGraphs ) do
	print("Graph " .. k .. ":")
	ConnectedComponents( graph )
	print("\n")
end

print("\n\n----------- BIPARTITE -----------")
for k, graph in pairs( undirectedGraphs ) do
	print("Graph " .. k .. ":")
	FindandPrintBipartiteGraphs( graph )
end

print("\n\n----------- CYCLES -----------")
for k, graph in pairs( directedGraphs ) do
	print("Graph " .. k .. ":")
	print( graph:hasCycle() )
end